﻿using ReflectionStudio.Components.UserControls;
using ReflectionStudio.Core.Events;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Windows;
using System.Data;
namespace WPFExcelReport
{
    public partial class GTTEK05
    {
       
        #region ==IsChgLS===========
        public static readonly DependencyProperty IsChgLSProperty = DependencyProperty.Register("IsChgLS",
            typeof(bool), typeof(GTTEK05),
            new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnIsChgLSChanged));
        public bool IsChgLS
        {
            get
            {
                return (bool)GetValue(IsChgLSProperty);
            }
            set
            {
                SetValue(IsChgLSProperty, value);
            }
        }
        private static void OnIsChgLSChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as GTTEK05;
            if (src != null)
            {
                src.IsChgLS = (bool)e.NewValue;
            }
        }
        #endregion
        ApplicationBase app
        {
            get
            {
                return ApplicationBase.Instance;
            }
        }
        public DataTable TBPRG
        {
            get
            {
                return app.TBPRG;
            }
            set
            {
                app.TBPRG = value;
            }
        }
        public DataTable TBUR
        {
            get
            {
                return app.TBUR;
            }
            set
            {
                app.TBUR = value;
            }
        }

       
        public GTTEK05()
        { 
            InitializeComponent();
            this.Name = "采购管理";
            SetUp();
        }
        private void SetUp()
        {
            List<string> deftxt = new List<string>();
            deftxt = new List<string>();


        }
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            if (IsLoaded)
                return;
            SetUpUserRight();
            IsLoaded = true;
        }
        public override void SetUpUserRight()
        {
            base.SetUpUserRight();
            Type mom = this.GetType();
            if (mom == null)
                return;
            string filter = "USERID='" + app.User + "' AND PROG='" + mom.Name.PadRight(80) + "'";
            DataRow[] rows = TBUR.Select(filter);
            foreach (DataRow row in rows)
            {
                string contol = row["CONTROLS"].ToString();//属性 
                string PROCESS = row["PROCESS"].ToString();//控制值
                string txt = row["P0"].ToString();//文本值 
                bool blControl = true;
                if (PROCESS.Trim() == "N")
                {
                    blControl = false; ;
                }
                if (PROCESS.Trim() == "Y")
                {
                    blControl = true; ;
                }
                switch (contol.Trim())
                {
                    case "DEL":
                        IsCanDelete = blControl;
                        break;
                    case "NEW":
                        IsCanNew = blControl;
                        break;
                    case "CHG":
                        IsCanChg = blControl;
                        break;
                    case "COPY":
                        IsCanCopy = blControl;
                        break;
                    case "MS":
                        ScopeManage = txt;
                        break;
                }
            }
        }
    }
}
